// pages/SystemNotification/index.js

const app = getApp()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    currentData: 0,
    system: [],
    member: [],
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    
  },
  onShow(){
    wx.showLoading({
      title: '获取中...',
    })
    this.getNotice()
  },
  getNotice(){
    var that = this,system=[],member=[];
    wx.request({
      url: app.globalData.basicUrl+'user/notice/list',
      success:function(res){
        console.log(res);
        res.data.rows.map(item=>{
          if (item.noticeType=='0') {
            system.push(item)
          }else{
            member.push(item)
          }
        })
        that.setData({
          system:system,
          member:member
        })
        wx.hideLoading()
      },
      fail(res){
        wx.hideLoading()
        wx.showToast({
          icon:'none',
          title: '获取失败！',
        })
      }
    })
  },
  //获取当前滑块的index
  bindchange: function (e) {
    const that = this;
    that.setData({
      currentData: e.detail.current
    })
  },
  //点击切换，滑块index赋值
  checkCurrent: function (e) {
    const that = this;

    if (that.data.currentData === e.target.dataset.current) {
      return false;
    } else {
      that.setData({
        currentData: e.target.dataset.current
      })
    }
  },
  system:function(e){
    console.log("获取当前的值",e);
    wx.navigateTo({
      url: '/pages/noticeDetails/index?nid='+e.currentTarget.dataset.index,
    })
  }
})